import config from "@/config"
import http from "@/utils/request"


// 分页获取兵役信息
export const getRegisterInfo = {
    url: `${config.BASE_URL}/military/getList`,
    name: "分页展示兵役信息",
    get: async function (param = {}) {
        return await http.get(this.url + `?page=${param.currentPage}&pageSize=${param.pageSize}`, param)
    }
}

// 新增兵役信息
export const addRegisterInfo = {
    url: `${config.BASE_URL}/military/add`,
    name: "新增兵役信息",
    post: async function (data) {
        return await http.post(this.url, data)
    }
}

// 导出兵役信息列表
export async function exportRegisterInfo() {
    let res = await fetch(`${config.BASE_URL}/military/export`, {
        method: 'post',
        headers: {
            'Content-Type': 'application/json',
        }
    }).then(res => res.blob()).then(data => {
        var blobUrl = window.URL.createObjectURL(data);
        return blobUrl
    })
    return res
}

// 获取详细的兵役信息
export const getRegisterDetails = {

}

// 删除单个兵役信息
export const delSingleRegister = {
    url: `${config.BASE_URL}/military/removeById`,
    name: '删除单个兵役信息',
    delete: async function (data) {
        return await http.delete(this.url + `/${data}`)
    }
}

// 批量删除兵役信息
export const delBatchRegister = {
    url: `${config.BASE_URL}/military/removeByIds`,
    name: "批量删除",
    delete: async function(data) {
        return await http.delete(this.url,data)
    }
}

// 条件查询兵役信息
export const selectRegister = {

}

// 修改兵役信息
export const updateRegister = {
    url: `${config.BASE_URL}/military/update`,
    name: '修改兵役信息',
    put: async function (data) {
        return await http.put(this.url, data)
    }
}

// 高级检索
export const allSearchInfo = {
    url: `${config.BASE_URL}/military/select/Advance`,
    name: '高级检索',
    post: async function(data) {
        return await http.post(this.url+`?age=${data.age}&idCard=${data.idCard}&name=${data.name}&sex=${data.sex}`)
    }
}

// 根据姓名查询
export const searchName = {
    url: `${config.BASE_URL}/military/select/name?name`,
    name: '姓名检索',
    post: async function(data) {
        return await http.post(this.url+`=${data}`)
    }
}